# -*- encoding:utf-8 -*-
# @time:2023-04-02 17:28
# @Author : serein
# @Email: serein@qq.com
# @File:serializers.py
# @Software: PyCharm

from rest_framework import serializers

from work.models import Lable, Topic


class Lableserializers(serializers.ModelSerializer):
    username = serializers.CharField(source="user.username",read_only=True)#通过正向查询查询出username
    class Meta:
        model = Lable
        fields = '__all__'
        extra_kwargs = {
            'user':{
                'required': False,
                'write_only': True
            }
        }

class Topicserializers(serializers.ModelSerializer):
    label_name = serializers.CharField(source='label.name', read_only=True)
    user_name = serializers.CharField(source='user.username', read_only=True)
    class Meta:
        model = Topic
        fields = '__all__'





